aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/funds/[id]/sweep/+page.server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-11-09 16:49:10 -0800
committerAdam Soltys <[email protected]>2023-11-11 00:04:22 -0800
commitefdbc67c17fab67bf3cdce448a30aa82f62c5212 (patch)
tree8af4f6245ea63e0b8a2d36f5da88439fc8d38ff7 /src/routes/(app)/funds/[id]/sweep/+page.server.js
parent9d554851a47ca9b4efd38f2682f313bd2623f8bf (diff)
downloadcoinos-ui-efdbc67c17fab67bf3cdce448a30aa82f62c5212.tar.gz
coinos-ui-efdbc67c17fab67bf3cdce448a30aa82f62c5212.zip
funds
Diffstat (limited to 'src/routes/(app)/funds/[id]/sweep/+page.server.js')
-rw-r--r--src/routes/(app)/funds/[id]/sweep/+page.server.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/routes/(app)/funds/[id]/sweep/+page.server.js b/src/routes/(app)/funds/[id]/sweep/+page.server.js
new file mode 100644
index 00000000..9fd244a3
--- /dev/null
+++ b/src/routes/(app)/funds/[id]/sweep/+page.server.js
@@ -0,0 +1,14 @@
+import { get, auth, post } from '$lib/utils';
+import { redirect } from '@sveltejs/kit';
+
+export async function load({ cookies, params, parent }) {
+ let { user } = await parent();
+ let { id } = params;
+ let { amount } = await get(`/fund/${id}`);
+
+
+ if (!amount) throw redirect(307, `/fund/${id}`);
+ if (!user) throw redirect(307, `/register?redirect=/fund/${id}/sweep`);
+ await post('/take', { amount, id }, auth(cookies));
+ return { amount, id };
+}